<?
if(!defined ('U_MOD'))
{
	echo"<meta http-equiv='refresh' content='0;url=/index.php'>";
	exit;
}

include 'topmenu.php';
$avialable_langs = explode(",", $option['avialable_langs']);
$avialable_langs_desc = explode(",", $option['avialable_langs_desc']);

if (!isset($lang) || empty($lang) || $lang=='' || is_numeric($lang))
{
	$langSelected=$option['default_lang'];
}else
	$langSelected=$lang;

if (!isset($mkey) || empty($mkey) || $mkey=='' || is_numeric($mkey))
{
	$moduleSelected='portal';
}else
	$moduleSelected=$mkey;

print'<p><table align="center" width="70%">
	<tr>
		<td id="column-title">'._LANG_CODE_.'</td>
		<td id="column-title">'._LANG_DESC_.'</td>
		<td id="column-title">'._DOACT_.'</td>
		<td id="column-title">'._SORT_.'</td>
	</tr>';
	$dd=1;
	$max=count($avialable_langs);
	for($i=0; $i<$max; $i++)
	{
		if ($i==1)
		{
			if($i!=($max-1))
				$arrowIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=3&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/down.png" id="img-action" title="'._GO_DOWN_TITLE_.'"></a>';
		}elseif($i>1 && $i<($max-1))
		{
			$arrowIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=3&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/down.png" id="img-action" title="'._GO_DOWN_TITLE_.'"></a><a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=4&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/up.png" id="img-action" title="'._GO_UP_TITLE_.'"></a>';
		}elseif($i==($max-1))
		{
			$arrowIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=4&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/up.png" id="img-action" title="'._GO_UP_TITLE_.'"></a>';
		}

		if ($max==1)
			$arrowIcon='';

		if ($avialable_langs[$i]==$option['default_lang'])
		{
			$sysIcon='<img src="'.$portal_url.'/images/icon/16x16_png/alert.png" id="img-action" title="'._DEFAULT_LANG_TITLE_.'">';
			$delIcon='';
			$DefaultIcon='<img src="'.$portal_url.'/images/icon/16x16_png/yes.png" id="img-action" title="'._DEFAULT_LANG_TITLE_Y_.'" >';
		}else
		{
			$sysIcon='';
			$delIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=1&lid='.$avialable_langs[$i].'" onClick="return confirm(\''._CLICKDEL_.' '._THISLANGS_.': '.$avialable_langs_desc[$i].'\');"><img src="'.$portal_url.'/images/icon/16x16_png/delete.png" id="img-action" title="'._DEL_TITLE_.'"></a>';
			$DefaultIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=2&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/warning.png" id="img-action" title="'._DEFAULT_LANG_TITLE_MAKE_.'" ></a>';
		}

		$modifyIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=managelang&act=3&lid='.$avialable_langs[$i].'"><img src="'.$portal_url.'/images/icon/16x16_png/modify.png" id="img-action" title="'._MODIFY_TITLE_.'"></a>';

		$dd++;$iclass = ($dd % 2) ? "even" : "odd";
		print '<tr id="'.$iclass.'">
			<td><img src="'.$portal_url.'/images/flags/16x16/'.$avialable_langs[$i].'.png" id="img-action">&nbsp;'.$avialable_langs[$i].'</td>
			<td>'.$avialable_langs_desc[$i].'</td>
			<td id="column-action">'.$DefaultIcon.''.$modifyIcon.''.$delIcon.''.$sysIcon.'</td>
			<td id="column-action">'.$arrowIcon.'</td>
		</tr>';
	}
print'</table></p>';


print '<form name="langSelect" method="post" action="'.$portal_url.'/admin.php?amk='.$amk.'">
	<select name="lang">
		<option value="-1">'._SELECT_LANG_.'</option>';
		GetLangsList($avialable_langs, $avialable_langs_desc, $langSelected);
	print'</select> &nbsp;';
	GetModuleList($moduleSelected,1,'mkey',_FOR_ALL_,'','');
	print'<input type="text" name="value_srch">
	<input type="submit" value="'._OK_.'">
</form>';

print '<hr>';

if ($moduleSelected=='all')
	$queryLangValueAdd='';
else
	$queryLangValueAdd="WHERE lang_module='".$moduleSelected."'";

if (!isset($value_srch) || empty($value_srch) || $value_srch=='')
	$queryLangValue=mysql_query("SELECT * FROM ".$PortalPref."langs_".$langSelected." ".$queryLangValueAdd);
else
{
	if ($queryLangValueAdd=='')
		$SearchAdd="WHERE lang_value LIKE '%".$value_srch."%' OR lang_param LIKE '%".$value_srch."%'";
	else
		$SearchAdd="AND (lang_value LIKE '%".$value_srch."%' OR lang_param LIKE '%".$value_srch."%')";
	$queryLangValue=mysql_query("SELECT * FROM ".$PortalPref."langs_".$langSelected." ".$queryLangValueAdd." ".$SearchAdd);
}

print '<table align="center" width="100%">
	<tr>
		<td id="column-title">'._LANG_PARAM_.'</td>
		<td id="column-title">'._LANG_VALUE_.'</td>
		<td id="column-title">'._DOACT_.'</td>
	</tr>';
		$dd=1;
		while($resultLangValue=mysql_fetch_assoc($queryLangValue))
		{
			$modifyIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=manage&act=3&lvid='.$resultLangValue['lang_param'].'&mod='.$resultLangValue['lang_module'].'"><img src="'.$portal_url.'/images/icon/16x16_png/modify.png" id="img-action" title="'._MODIFY_TITLE_.'"></a>';
			$delIcon='<a href="'.$portal_url.'/admin.php?amk='.$amk.'&apk=change&act=5&lvid='.$resultLangValue['lang_param'].'&mod='.$resultLangValue['lang_module'].'" onClick="return confirm(\''._CLICKDEL_.' '._THISCONSTANT_.': '.$resultLangValue['lang_param'].'\');"><img src="'.$portal_url.'/images/icon/16x16_png/delete.png" id="img-action" title="'._DEL_TITLE_.'"></a>';

			$dd++;$iclass = ($dd % 2) ? "even" : "odd";
			print '<tr id="'.$iclass.'">
				<td>'.$resultLangValue['lang_param'].'</td>
				<td>'.$resultLangValue['lang_value'].'</td>
				<td id="column-action">'.$modifyIcon.''.$delIcon.'</td>
			</tr>';
		}
print '</table>';
?>